﻿Module Module1

    Private _FileLastAccessTime() As String = {"arq ultimo acesso", "file last access"}
    Private _WatchAtivityOnDirectory() As String = {"watch dir act", "activity on directory"}
    Private _DirectoryCreationTime() As String = {"directory creation time", "nascimento diretorio"}
    Private _Sair() As String = {"exit", "sair", "fim"}
    Private _arraYArrays As List(Of String())

    Sub Main()

        'criar menu
        'exibir opções de menu
        '1. vigia os arquivos alterados de uma certa pasta

        'DirectoryUTCTime.Main()
        'DirectoryCreationTime.Main()
        'WatchAtivityOnDirectory.Main()
        'FileLastAccessTime.Main()

        'Dim menu As System.ConsoleKey
        Dim _comandoOriginal, _comandoTraduzido As String

        _arraYArrays = New List(Of String())
        _arraYArrays.Add(_FileLastAccessTime)
        _arraYArrays.Add(_WatchAtivityOnDirectory)
        _arraYArrays.Add(_DirectoryCreationTime)
        _arraYArrays.Add(_Sair)
        
        Console.WriteLine()
        While True
            ShowMenu()
            _comandoOriginal = Console.ReadLine()
            _comandoTraduzido = TraduzComando(_comandoOriginal)
            Select Case _comandoTraduzido
                Case _FileLastAccessTime(0)
                    FileLastAccessTime.Main()
                Case _WatchAtivityOnDirectory(0)
                    WatchAtivityOnDirectory.Main()
                Case _DirectoryCreationTime(0)
                    DirectoryCreationTime.Main()
                Case _Sair(0)
                    Exit While
                Case Else
                    Console.WriteLine("Comando não reconhecido")
            End Select
        End While

        'Console.ReadKey()

    End Sub


    Function TraduzComando(ByVal _comando As String)
        'Dim _FileLastAccessTime() As String = {"arq ultimo acesso", "file last access"}
        'Dim _WatchAtivityOnDirectory() As String = {"watch dir act", "activity on directory"}


        If _FileLastAccessTime.Contains(_comando) Then Return _FileLastAccessTime(0)
        If _WatchAtivityOnDirectory.Contains(_comando) Then Return _WatchAtivityOnDirectory(0)
        If _DirectoryCreationTime.Contains(_comando) Then Return _DirectoryCreationTime(0)
        If _Sair.Contains(_comando) Then Return _Sair(0)

        Dim q1 = From c In _FileLastAccessTime Where c.Contains(_comando) Select c
        If q1.Count > 0 Then Return _FileLastAccessTime(0)

        Dim q2 = From c In _WatchAtivityOnDirectory Where c.Contains(_comando) Select c
        If q2.Count > 0 Then Return _WatchAtivityOnDirectory(0)

        Dim q3 = From c In _DirectoryCreationTime Where c.Contains(_comando) Select c
        If q3.Count > 0 Then Return _DirectoryCreationTime(0)

        Return _comando

    End Function

    Sub ShowMenu()
        Console.WriteLine("---- MENU ---")
        For i = 0 To (_arraYArrays.Count - 1)
            Console.WriteLine("{0} - {1}", i + 1, _arraYArrays(i)(0))
        Next
    End Sub


End Module


'QUE TAL REALIZAR TESTES EM TODOS OS ITENS ABAIXO
'SYSTEM IO
'http://msdn.microsoft.com/pt-br/library/system.io.file.getlastaccesstime.aspx
'http://msdn.microsoft.com/pt-br/library/System.IO.aspx